package com.one.util;

import com.one.constant.RequestReturnConstant;
import lombok.Data;

import java.util.Collection;


@Data
public class PageSupport<T> {
    //当前页码
    private int currPageNo= RequestReturnConstant.UNIFY_RETURN_INT_PAGE_NO;

    //查询条数,每一页的展示条数
    private int pageSize = RequestReturnConstant.UNIFY_RETURN_INIT_PAGE_SIZE;

    //总条数
    private int totalCount;

    //总页数
    private int totalPage;

    //当前分页数据
    private Collection<T> Pagedata;




    //当确定总条数的时候，可以根据页面容量确定总页数
    public void setTotalCount(int totalCount) {
      if(totalCount>0){
          this.totalCount = totalCount;
          this.totalPage = this.pageSize % this.pageSize == 0 ? this.totalCount / this.pageSize : this.totalCount / this.pageSize +1;
      }
    }
}
